package com.project.weather.controller;

import com.project.weather.aspectj.Log;
import com.project.weather.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import io.swagger.annotations.*;
import com.project.weather.common.PageBean;
import com.project.weather.common.AResultCode;
import com.project.weather.common.ResultMap;
import com.project.weather.pojo.SearchCityBean;
import com.project.weather.service.SearchCityService;

/**
 *<p>Title:SearchCityController.java</p>
 *<p>Description:城市查询信息表 Action</p>
 *@author xxx
 *@version 1.0
 *@Automatically generate by Coder in 2021-12-21 16:07
 */
@RestController
@RequestMapping(name="城市查询信息表", value="/searchcity/")
@Api(tags = {"城市查询信息表 Api 接口文档"})
public class SearchCityController {
	private static final Logger log = LoggerFactory.getLogger(SearchCityController.class);
	@Autowired
	private SearchCityService searchCityService;

	@ApiOperation(value="新增接口")
	@Log(title = "城市查询次数", businessType = BusinessType.INSERT)
	@Transactional
	@RequestMapping(name="新增接口",value="insert.json",method = RequestMethod.POST)
	public ResultMap<AResultCode, SearchCityBean> insert(@ApiParam(value = "对象数据", required = true) @RequestBody SearchCityBean bean){
		return searchCityService.insert(bean);
	}

	@ApiOperation(value="修改接口")
	@Log(title = "城市查询次数", businessType = BusinessType.UPDATE)
	@Transactional
	@RequestMapping(name="修改接口",value="update.json",method = RequestMethod.POST)
	public ResultMap<AResultCode, SearchCityBean> update(@ApiParam(value = "对象数据", required = true) @RequestBody SearchCityBean bean){
		return searchCityService.update(bean);
	}

	@ApiOperation(value="删除接口")
	@Log(title = "城市查询次数", businessType = BusinessType.DELETE)
	@ApiImplicitParam(name = "id", value = "主键ID", required = true, paramType = "query")
	@RequestMapping(name="删除接口",value="delete.json",method = RequestMethod.GET)
	@Transactional
	public ResultMap<AResultCode, SearchCityBean> delete(@RequestParam("id") String id){
		return searchCityService.delete(id);
	}

	@ApiOperation(value="分页查询列表接口")
	@Log(title = "城市查询次数", businessType = BusinessType.LIST)
	@RequestMapping(name="分页查询列表接口",value="pageList.json",method = RequestMethod.POST)
	public ResultMap<AResultCode, PageBean<SearchCityBean>> pageList(@ApiParam(value = "分页对象数据", required = true) @RequestBody PageBean<SearchCityBean> pb){
		pb.init(pb,SearchCityBean.class);	//需要调用init，将页面传来的json条件转换为bean
		return searchCityService.pageList(pb);
	}

	@ApiOperation(value="分页查询列表接口")
	@Log(title = "城市查询次数", businessType = BusinessType.LIST)
	@RequestMapping(name="分页查询列表接口",value="countPageList.json",method = RequestMethod.POST)
	public ResultMap<AResultCode, PageBean<SearchCityBean>> countPageList(@ApiParam(value = "分页对象数据", required = true) @RequestBody PageBean<SearchCityBean> pb){
		pb.init(pb,SearchCityBean.class);	//需要调用init，将页面传来的json条件转换为bean
		return searchCityService.countPageList(pb);
	}

	@ApiOperation(value="查询所有数据接口")
	@Log(title = "城市查询次数", businessType = BusinessType.LIST)
	@RequestMapping(name="查询所有数据接口",value="list.json",method = RequestMethod.POST)
	public ResultMap<AResultCode, List<SearchCityBean>> list(@ApiParam(value = "对象数据", required = true) @RequestBody(required = false) SearchCityBean bean){
		return searchCityService.list(bean);
	}

	@ApiOperation(value="根据主键获取数据接口")
	@Log(title = "城市查询次数", businessType = BusinessType.LIST)
	@ApiImplicitParam(name = "id", value = "主键ID", required = true, paramType = "query")
	@RequestMapping(name="根据主键获取数据接口",value="get.json",method = RequestMethod.GET)
	public ResultMap<AResultCode, SearchCityBean> get(String id){
		return searchCityService.get(id);
	}
	
}